/**
 * 
 * @fileOverview View control for posting device changes. On success, redirects
 *               back to edit device. Needs to be redesigned to allow add-update-remove
 * @author jmanero
 * 
 */


var util = require('util');

/** @ignore */
exports.callback = function(req, res) {
	model.Device.update({
		hwAddress : req.params.device
	}, {
		status : 'offline',
		name : req.body.name,
		location : req.body.location,
		description : req.body.description
	}, function(e) {
		model.Message.error(e);
	});
	res.redirect('https://' + req.header('X-Request-Host') + '/devices/'
			+ req.params.device);
};

/** @ignore */
exports.path = '/devices/:device';

/** @ignore */
exports.method = 'post';
